#include<algorithm>
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<string.h>
using namespace std;

bool cmp(string a,string b){
    int i=0;
    while(i<a.length() && i<b.length()){
        if(a[i]!=b[i]){return a[i]<b[i];}
        i++;
    }
    int ans1=stoi(a+b);
    int ans2=stoi(b+a);
    return ans1<ans2;
}

vector<string> inp;
int main(){
    //freopen("in.txt","r",stdin);
    string tmp;
    int N;
    scanf("%d",&N);
    tmp.resize(5);
    for(int i=0;i<N;i++){
        cin>>tmp;
        inp.push_back(tmp);
    }
    sort(inp.begin(),inp.end(),cmp);
    string ans="";
    for(int i=0;i<inp.size();i++){
        ans+=inp[i];
    }
    int idx=-1;
    for(int i=0;i<ans.length();i++){
        if('1'<=ans[i] && ans[i]<='9'){
            idx=i;break;
        }
    }
    if(idx==-1){
        printf("0\n");
        return 0;
    }
    ans.erase(0,idx);
    printf("%s",ans.c_str());
}
